package com.nondo.dean.platform.controller.api.inner;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.nondo.dean.common.annotation.ApiVersion;
import com.nondo.dean.common.web.View;
import com.nondo.dean.platform.model.ZoneBean;
import com.nondo.dean.platform.model.result.ZoneResult;
import com.nondo.dean.platform.service.ZoneService;

/**
 * 区域管理内部接口
 * @author zlj
 * @date 2018年4月8日
 */
@RestController("apiInnerZone")
@RequestMapping("/{v}/inner/zone")
public class ZoneController {
    
    @Autowired
    ZoneService zoneService;
    
    /**
     * 获取区域列表
     * @param request
     * @param response
     * @return
     */
    @ApiVersion(1)
    @RequestMapping("/list/all")
    public View<List<ZoneBean>> list(HttpServletRequest request, HttpServletResponse response) {
        View<List<ZoneBean>> view = new View<List<ZoneBean>>(20000, "获取列表成功");

        List<ZoneBean> zoneList = zoneService.getZoneList();
        
        view.setData(zoneList);
        
        return view;
    }
    
    /**
     * 获取区域省份两级列表
     * @param request
     * @param response
     * @return
     */
    @ApiVersion(1)
    @RequestMapping("/list/province")
    public View<List<ZoneResult>> listProvince(HttpServletRequest request, HttpServletResponse response) {
        View<List<ZoneResult>> view = new View<List<ZoneResult>>(20000, "获取列表成功");

        List<ZoneResult> zoneResultList = zoneService.getZoneProvinceList();
        
        view.setData(zoneResultList);
        
        return view;
    }
}